import os
import pyautogui
import uiautomation
from config.config import DATA_PATH
from page.index import IndexPage
from page.门诊医生站.menzhentuifang__page import Menzhentuifang
from tools.sjqd_way import read_data_from_excel


class Tiaoshi():
    his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
    his.SetFocus()
    def menzhentuifang(self):
        self.data = read_data_from_excel(os.path.join(DATA_PATH, "datas.xls"), "测试患者")
        name = self.data[0][0]
        ap = IndexPage()
        bp = Menzhentuifang()
        ap.click_mzysz1_btn()#点击门诊医生站
        ap.click_mztf_btn()#点击门诊退方
        bp.input_hzxm(name)#输入患者姓名
        bp.click_chaxun_btn()#点击查询按钮
        bp.click_chufang1()#点击第一条数据
        bp.click_tuifang_btn()#点击退方按钮
        bp.click_tishiqueding_btn()#点击确定按钮
        bp.click_chufang2()  # 点击第二条数据
        bp.click_tuifang_btn()  # 点击退方按钮
        bp.tishi.Refind()
        bp.tishiqueding.Refind()
        bp.click_tishiqueding_btn()  # 点击确定按钮
    def quxiaotuifang(self):
        bp = Menzhentuifang()
        bp.chufang1.Refind()
        bp.click_chufang1()#点击第一条数据
        bp.click_quxiaotuifang_btn()#点击取消退方按钮
        bp.chufang2.Refind()
        bp.click_chufang2()  # 点击第二条数据
        bp.click_quxiaotuifang_btn()#点击取消退方按钮

if __name__ == '__main__':
    Tiaoshi().menzhentuifang()
    # Tiaoshi().quxiaotuifang()

